#include <functional>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> a;
    for(int i = 0; i < n; i++) {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(a.begin(), a.end());
    vector<int> b(n);
    for(int i = 0; i < n; i++) {
        b[i] = a[i] + n - i;
    }
    int Max = 0;
    for(int i = 0; i < n; i++) {
        Max = max(Max, b[i]);
    }
    int ret = 0;
    for(int i = n - 1; i >= 0; i--) {
        if(a[i] + n >= Max) {
            ret++;
        }
    }
    cout << ret << endl;
    return 0;
}